package com.hant.order1.service.provider;

import com.hant.shopserivce.api.service.order.RpcShopOrderService;
import com.hant.shopserivce.api.service.user.RpcShopUserService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;

/**
 * 接口实现类
 *
 * ## @Service 这个注解是使用dubbo提供的，
 *             这个注解中有很多属性，需要单独了解去进行配置
 *  loadbalance 多种模式 random 随机，roundrobin 轮询 ...
 * @author raysonfang
 */
@Service(loadbalance = "roundrobin")
public class ShopOrderServiceImpl implements RpcShopOrderService {

    /**
     *  @author: HanJieTao
     *  @Date: 2021/4/25 21:40
     *  @Description: 懒加载解决，服务提供者相互提供服务导致的启动失败问题
     */
    @Reference(lazy = true)
    private RpcShopUserService rpcShopUserService;

    @Override
    public String queryOrder(String name) {
        String userResult = rpcShopUserService.queryUser("test can");
        return "order1 provide"+name + " 8888 " + userResult;
    }
}
